package com.demo.demo4;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 转账案例业务层实现类
 * @Transactional 中的注解属性：
 *  propagation     :事务传播行为
 *  isolation       :事务隔离级别
 *  readOnly        :只读信息
 *  rollbackFor     :发生哪些异常回滚
 *  noRollbackFor   :发生哪些异常不回滚
 */
@Service("accountService")
@Transactional(
    propagation = Propagation.REQUIRED,
    isolation = Isolation.DEFAULT,
    readOnly = false
)
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDao accountDao;
    public void transfer(String out, String in, Double money) {
        accountDao.outMoney(out, money);
        // int i = 1 / 0;
        accountDao.inMoney(in, money);
    }
}
